package userService

import (
	"gin-gorm-oj/models"
	"gin-gorm-oj/response"
	"github.com/gin-gonic/gin"
	"strconv"
)

func GetCategoryList(c *gin.Context) {
	typec, err := strconv.Atoi(c.Query("type"))
	if err != nil {
		response.ResponseBadRequest(c)
	}
	var categoryList []models.Category
	err = models.Db.Where("type = ?", typec).Find(&categoryList).Error
	if err != nil {
		response.ResponseInternalServerError(c)
	}
	response.ResponseOK(c, categoryList)
	return
}
